import org.pentaho.di.repository.RepositoriesMeta
import org.pentaho.di.repository.RepositoryMeta
import org.pentaho.di.core.logging.LogWriter

class RepoService {

    boolean transactional = true

    def listRepositories() {
        def lst = []

        LogWriter log = LogWriter.getInstance(LogWriter.LOG_LEVEL_BASIC);
        
        RepositoriesMeta ri = new RepositoriesMeta(log)
        if (ri.readData()) {
            for(int i=0;i<ri.nrRepositories();i++) {
                RepositoryMeta rinfo = ri.getRepository(i)
                lst << rinfo.getName()
            }
        }
        else {
            lst << "None."
        }
        return lst
    }

    def listJobs() {

        String jobnames[] = repository.getJobNames(directory.getID());
        for (int i=0;i<jobnames.length;i++)
        {
        System.out.println(jobnames[i]);
        }
    }
}
